extends BaseEnemy

const VELOCITY = Vector2(0, 1)
const SPEED = 100.0
const SPATIAL_TRANSITION_SPEED = 350

@onready var enemy_sprite: Sprite2D = $EnemySprite

var speed: float = SPEED
var pending_damage
#横飞的方向，默认向左
var sideways_velocity = Vector2(1, 0)

func _physics_process(_delta: float) -> void:
	if pending_damage:
		state_machine.change_state("Hurt")

func _on_hurtbox_hurt(hitbox: Hitbox) -> void:
	pending_damage = Damage.new()
	pending_damage.amount = Game.calculate_damage(hitbox.owner, self)
	pending_damage.source = hitbox.owner
